diff --git a/src/app/Mail/DegradedAccountReminder.php b/src/app/Mail/DegradedAccountReminder.php --- a/src/app/Mail/DegradedAccountReminder.php +++ b/src/app/Mail/DegradedAccountReminder.php @@ -37,15 +37,17 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.degradedaccountreminder-subject', ['site' => $appName]); + $vars = [ + 'email' => $this->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.degraded_account_reminder') ->text('emails.plain.degraded_account_reminder') - ->subject($subject) + ->subject(\trans('mail.degradedaccountreminder-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), 'dashboardUrl' => Utils::serviceUrl('/dashboard', $this->user->tenant_id), @@ -65,6 +67,8 @@ { $wallet = new Wallet(); $user = new User(); + $user->email = 'test@' . \config('app.domain'); + $wallet->owner = $user; $mail = new self($wallet, $user); diff --git a/src/app/Mail/NegativeBalance.php b/src/app/Mail/NegativeBalance.php --- a/src/app/Mail/NegativeBalance.php +++ b/src/app/Mail/NegativeBalance.php @@ -37,15 +37,17 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.negativebalance-subject', ['site' => $appName]); + $vars = [ + 'email' => $this->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.negative_balance') ->text('emails.plain.negative_balance') - ->subject($subject) + ->subject(\trans('mail.negativebalance-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), ]); @@ -64,6 +66,8 @@ { $wallet = new Wallet(); $user = new User(); + $user->email = 'test@' . \config('app.domain'); + $wallet->owner = $user; $mail = new self($wallet, $user); diff --git a/src/app/Mail/NegativeBalanceDegraded.php b/src/app/Mail/NegativeBalanceDegraded.php --- a/src/app/Mail/NegativeBalanceDegraded.php +++ b/src/app/Mail/NegativeBalanceDegraded.php @@ -38,15 +38,17 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.negativebalancedegraded-subject', ['site' => $appName]); + $vars = [ + 'email' => $this->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.negative_balance_degraded') ->text('emails.plain.negative_balance_degraded') - ->subject($subject) + ->subject(\trans('mail.negativebalancedegraded-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), ]); @@ -65,6 +67,8 @@ { $wallet = new Wallet(); $user = new User(); + $user->email = 'test@' . \config('app.domain'); + $wallet->owner = $user; $mail = new self($wallet, $user); diff --git a/src/app/Mail/NegativeBalanceReminderDegrade.php b/src/app/Mail/NegativeBalanceReminderDegrade.php --- a/src/app/Mail/NegativeBalanceReminderDegrade.php +++ b/src/app/Mail/NegativeBalanceReminderDegrade.php @@ -39,18 +39,20 @@ $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); $threshold = WalletCheck::threshold($this->wallet, WalletCheck::THRESHOLD_DEGRADE); - $subject = \trans('mail.negativebalancereminderdegrade-subject', ['site' => $appName]); + $vars = [ + 'date' => $threshold->toDateString(), + 'email' => $this->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.negative_balance_reminder_degrade') ->text('emails.plain.negative_balance_reminder_degrade') - ->subject($subject) + ->subject(\trans('mail.negativebalancereminderdegrade-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), - 'date' => $threshold->toDateString(), ]); return $this; @@ -67,6 +69,8 @@ { $wallet = new Wallet(); $user = new User(); + $user->email = 'test@' . \config('app.domain'); + $wallet->owner = $user; $mail = new self($wallet, $user); diff --git a/src/app/Mail/PasswordExpirationReminder.php b/src/app/Mail/PasswordExpirationReminder.php --- a/src/app/Mail/PasswordExpirationReminder.php +++ b/src/app/Mail/PasswordExpirationReminder.php @@ -36,17 +36,20 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $href = Utils::serviceUrl('profile', $this->user->tenant_id); - $params = [ - 'site' => $appName, + $vars = [ 'date' => $this->expiresOn, - 'link' => sprintf('%s', $href, $href), - 'username' => $this->user->name(true), + 'email' => $this->user->email, + 'name' => $this->user->name(true), + 'site' => $appName, ]; $this->view('emails.html.password_expiration_reminder') ->text('emails.plain.password_expiration_reminder') - ->subject(\trans('mail.passwordexpiration-subject', $params)) - ->with($params); + ->subject(\trans('mail.passwordexpiration-subject', $vars)) + ->with([ + 'vars' => $vars, + 'link' => sprintf('%s', $href, $href) + ]); return $this; } diff --git a/src/app/Mail/PasswordReset.php b/src/app/Mail/PasswordReset.php --- a/src/app/Mail/PasswordReset.php +++ b/src/app/Mail/PasswordReset.php @@ -41,15 +41,20 @@ $this->user->tenant_id ); + $vars = [ + 'email' => $this->user->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; + $this->view('emails.html.password_reset') ->text('emails.plain.password_reset') - ->subject(\trans('mail.passwordreset-subject', ['site' => $appName])) + ->subject(\trans('mail.passwordreset-subject', $vars)) ->with([ - 'site' => $appName, + 'vars' => $vars, + 'link' => sprintf('%s', $href, $href), 'code' => $this->code->code, 'short_code' => $this->code->short_code, - 'link' => sprintf('%s', $href, $href), - 'username' => $this->user->name(true) ]); return $this; diff --git a/src/app/Mail/PaymentFailure.php b/src/app/Mail/PaymentFailure.php --- a/src/app/Mail/PaymentFailure.php +++ b/src/app/Mail/PaymentFailure.php @@ -37,15 +37,17 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.paymentfailure-subject', ['site' => $appName]); + $vars = [ + 'email' => $this->payment->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.payment_failure') ->text('emails.plain.payment_failure') - ->subject($subject) + ->subject(\trans('mail.paymentfailure-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), ]); @@ -62,11 +64,14 @@ */ public static function fakeRender(string $type = 'mail'): string { - $payment = new Payment(); $user = new User([ 'email' => 'test@' . \config('app.domain'), ]); + $payment = new Payment(); + $payment->wallet = new \App\Wallet(); + $payment->wallet->owner = $user; + $mail = new self($payment, $user); return Helper::render($mail, $type); diff --git a/src/app/Mail/PaymentMandateDisabled.php b/src/app/Mail/PaymentMandateDisabled.php --- a/src/app/Mail/PaymentMandateDisabled.php +++ b/src/app/Mail/PaymentMandateDisabled.php @@ -37,15 +37,17 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.paymentmandatedisabled-subject', ['site' => $appName]); + $vars = [ + 'email' => $this->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.payment_mandate_disabled') ->text('emails.plain.payment_mandate_disabled') - ->subject($subject) + ->subject(\trans('mail.paymentmandatedisabled-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), ]); @@ -66,6 +68,7 @@ $user = new User([ 'email' => 'test@' . \config('app.domain'), ]); + $wallet->owner = $user; $mail = new self($wallet, $user); diff --git a/src/app/Mail/PaymentSuccess.php b/src/app/Mail/PaymentSuccess.php --- a/src/app/Mail/PaymentSuccess.php +++ b/src/app/Mail/PaymentSuccess.php @@ -37,15 +37,17 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.paymentsuccess-subject', ['site' => $appName]); + $vars = [ + 'email' => $this->payment->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.payment_success') ->text('emails.plain.payment_success') - ->subject($subject) + ->subject(\trans('mail.paymentsuccess-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), ]); @@ -62,11 +64,14 @@ */ public static function fakeRender(string $type = 'html'): string { - $payment = new Payment(); $user = new User([ 'email' => 'test@' . \config('app.domain'), ]); + $payment = new Payment(); + $payment->wallet = new \App\Wallet(); + $payment->wallet->owner = $user; + $mail = new self($payment, $user); return Helper::render($mail, $type); diff --git a/src/app/Mail/SignupInvitation.php b/src/app/Mail/SignupInvitation.php --- a/src/app/Mail/SignupInvitation.php +++ b/src/app/Mail/SignupInvitation.php @@ -36,11 +36,15 @@ $href = Utils::serviceUrl('/signup/invite/' . $this->invitation->id, $this->invitation->tenant_id); + $vars = [ + 'site' => $appName, + ]; + $this->view('emails.html.signup_invitation') ->text('emails.plain.signup_invitation') - ->subject(\trans('mail.signupinvitation-subject', ['site' => $appName])) + ->subject(\trans('mail.signupinvitation-subject', $vars)) ->with([ - 'site' => $appName, + 'vars' => $vars, 'href' => $href, ]); diff --git a/src/app/Mail/SignupVerification.php b/src/app/Mail/SignupVerification.php --- a/src/app/Mail/SignupVerification.php +++ b/src/app/Mail/SignupVerification.php @@ -41,15 +41,19 @@ } $username = trim($username); + $vars = [ + 'site' => \config('app.name'), + 'name' => $username ?: 'User', + ]; + $this->view('emails.html.signup_verification') ->text('emails.plain.signup_verification') - ->subject(\trans('mail.signupverification-subject', ['site' => \config('app.name')])) + ->subject(\trans('mail.signupverification-subject', $vars)) ->with([ - 'site' => \config('app.name'), - 'username' => $username ?: 'User', + 'vars' => $vars, + 'href' => $href, 'code' => $this->code->code, 'short_code' => $this->code->short_code, - 'href' => $href, ]); return $this; diff --git a/src/app/Mail/TrialEnd.php b/src/app/Mail/TrialEnd.php --- a/src/app/Mail/TrialEnd.php +++ b/src/app/Mail/TrialEnd.php @@ -31,15 +31,16 @@ $paymentUrl = Tenant::getConfig($this->user->tenant_id, 'app.kb.payment_system'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.trialend-subject', ['site' => $appName]); + $vars = [ + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.trial_end') ->text('emails.plain.trial_end') - ->subject($subject) + ->subject(\trans('mail.trialend-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'paymentUrl' => $paymentUrl, 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), ]); diff --git a/src/resources/lang/en/mail.php b/src/resources/lang/en/mail.php --- a/src/resources/lang/en/mail.php +++ b/src/resources/lang/en/mail.php @@ -18,7 +18,7 @@ 'more-info-text' => "See :href for more information.", 'degradedaccountreminder-subject' => ":site Reminder: Your account is free", - 'degradedaccountreminder-body1' => "Thanks for sticking around, we remind you your account is a free " + 'degradedaccountreminder-body1' => "Thanks for sticking around, we remind you your :email account is a free " . "account and restricted to receiving email, and use of the web client and cockpit only.", 'degradedaccountreminder-body2' => "This leaves you with an ideal account to use for account registration with third parties " . "and password resets, notifications or even just subscriptions to newsletters and the like.", @@ -28,12 +28,12 @@ 'degradedaccountreminder-body5' => "Thank you for your consideration!", 'negativebalance-subject' => ":site Payment Required", - 'negativebalance-body' => "This is a notification to let you know that your :site account balance has run into the negative and requires your attention. " + 'negativebalance-body' => "This is a notification to let you know that your :email account balance has run into the negative and requires your attention. " . "Consider setting up an automatic payment to avoid messages like this in the future.", 'negativebalance-body-ext' => "Settle up to keep your account running:", 'negativebalancereminderdegrade-subject' => ":site Payment Reminder", - 'negativebalancereminderdegrade-body' => "It has probably skipped your attention that you are behind on paying for your :site account. " + 'negativebalancereminderdegrade-body' => "It has probably skipped your attention that you are behind on paying for your :email account. " . "Consider setting up an automatic payment to avoid messages like this in the future.", 'negativebalancereminderdegrade-body-ext' => "Settle up to keep your account running:", @@ -41,21 +41,21 @@ . "if your account balance is not settled by :date.", 'negativebalancedegraded-subject' => ":site Account Degraded", - 'negativebalancedegraded-body' => "Your :site account has been degraded for having a negative balance for too long. " + 'negativebalancedegraded-body' => "Your :email account has been degraded for having a negative balance for too long. " . "Consider setting up an automatic payment to avoid messages like this in the future.", 'negativebalancedegraded-body-ext' => "Settle up now to undegrade your account:", 'passwordreset-subject' => ":site Password Reset", - 'passwordreset-body1' => "Someone recently asked to change your :site password.", + 'passwordreset-body1' => "Someone recently asked to change your :email password.", 'passwordreset-body2' => "If this was you, use this verification code to complete the process:", 'passwordreset-body3' => "You can also click the link below:", 'passwordreset-body4' => "If you did not make such a request, you can either ignore this message or get in touch with us about this incident.", 'passwordexpiration-subject' => ":site password expires on :date", - 'passwordexpiration-body' => "Your password will expire on :date. You can change it here:", + 'passwordexpiration-body' => "Your :email account password will expire on :date. You can change it here:", 'paymentmandatedisabled-subject' => ":site Auto-payment Problem", - 'paymentmandatedisabled-body' => "Your :site account balance is negative " + 'paymentmandatedisabled-body' => "Your :email account balance is negative " . "and the configured amount for automatically topping up the balance does not cover " . "the costs of subscriptions consumed.", 'paymentmandatedisabled-body-ext' => "Charging you multiple times for the same amount in short succession " @@ -64,7 +64,7 @@ . "To resolve this issue, login to your account settings and adjust your auto-payment amount.", 'paymentfailure-subject' => ":site Payment Failed", - 'paymentfailure-body' => "Something went wrong with auto-payment for your :site account.\n" + 'paymentfailure-body' => "Something went wrong with auto-payment for your :email account.\n" . "We tried to charge you via your preferred payment method, but the charge did not go through.", 'paymentfailure-body-ext' => "In order to not cause any further issues, we suspended auto-payment for your account. " . "To resolve this issue, login to your account settings at", @@ -72,7 +72,7 @@ . "change your auto-payment settings.", 'paymentsuccess-subject' => ":site Payment Succeeded", - 'paymentsuccess-body' => "The auto-payment for your :site account went through without issues. " + 'paymentsuccess-body' => "The auto-payment for your :email account went through without issues. " . "You can check your new account balance and more details here:", 'support' => "Special circumstances? Something is wrong with a charge?\n" diff --git a/src/resources/views/emails/html/degraded_account_reminder.blade.php b/src/resources/views/emails/html/degraded_account_reminder.blade.php --- a/src/resources/views/emails/html/degraded_account_reminder.blade.php +++ b/src/resources/views/emails/html/degraded_account_reminder.blade.php @@ -4,16 +4,16 @@ -

{{ __('mail.header', ['name' => $username]) }}

+

{{ __('mail.header', $vars) }}

-

{{ __('mail.degradedaccountreminder-body1', ['site' => $site]) }}

-

{{ __('mail.degradedaccountreminder-body2', ['site' => $site]) }}

-

{{ __('mail.degradedaccountreminder-body3', ['site' => $site]) }}

+

{{ __('mail.degradedaccountreminder-body1', $vars) }}

+

{{ __('mail.degradedaccountreminder-body2', $vars) }}

+

{{ __('mail.degradedaccountreminder-body3', $vars) }}

{{ $dashboardUrl }}

-

{{ __('mail.degradedaccountreminder-body4', ['site' => $site]) }}

-

{{ __('mail.degradedaccountreminder-body5', ['site' => $site]) }}

+

{{ __('mail.degradedaccountreminder-body4', $vars) }}

+

{{ __('mail.degradedaccountreminder-body5', $vars) }}

-

{{ __('mail.footer1') }}

-

{{ __('mail.footer2', ['site' => $site]) }}

+

{{ __('mail.footer1', $vars) }}

+

{{ __('mail.footer2', $vars) }}

diff --git a/src/resources/views/emails/html/negative_balance.blade.php b/src/resources/views/emails/html/negative_balance.blade.php --- a/src/resources/views/emails/html/negative_balance.blade.php +++ b/src/resources/views/emails/html/negative_balance.blade.php @@ -4,18 +4,18 @@ -

{{ __('mail.header', ['name' => $username]) }}

+

{{ __('mail.header', $vars) }}

-

{{ __('mail.negativebalance-body', ['site' => $site]) }}

-

{{ __('mail.negativebalance-body-ext', ['site' => $site]) }}

+

{{ __('mail.negativebalance-body', $vars) }}

+

{{ __('mail.negativebalance-body-ext', $vars) }}

{{ $walletUrl }}

@if ($supportUrl) -

{{ __('mail.support', ['site' => $site]) }}

+

{{ __('mail.support', $vars) }}

{{ $supportUrl }}

@endif -

{{ __('mail.footer1') }}

-

{{ __('mail.footer2', ['site' => $site]) }}

+

{{ __('mail.footer1', $vars) }}

+

{{ __('mail.footer2', $vars) }}

diff --git a/src/resources/views/emails/html/negative_balance_degraded.blade.php b/src/resources/views/emails/html/negative_balance_degraded.blade.php --- a/src/resources/views/emails/html/negative_balance_degraded.blade.php +++ b/src/resources/views/emails/html/negative_balance_degraded.blade.php @@ -4,18 +4,18 @@ -

{{ __('mail.header', ['name' => $username]) }}

+

{{ __('mail.header', $vars) }}

-

{{ __('mail.negativebalancedegraded-body', ['site' => $site]) }}

-

{{ __('mail.negativebalancedegraded-body-ext', ['site' => $site]) }}

+

{{ __('mail.negativebalancedegraded-body', $vars) }}

+

{{ __('mail.negativebalancedegraded-body-ext', $vars) }}

{{ $walletUrl }}

@if ($supportUrl) -

{{ __('mail.support', ['site' => $site]) }}

+

{{ __('mail.support', $vars) }}

{{ $supportUrl }}

@endif -

{{ __('mail.footer1') }}

-

{{ __('mail.footer2', ['site' => $site]) }}

+

{{ __('mail.footer1', $vars) }}

+

{{ __('mail.footer2', $vars) }}

diff --git a/src/resources/views/emails/html/negative_balance_reminder_degrade.blade.php b/src/resources/views/emails/html/negative_balance_reminder_degrade.blade.php --- a/src/resources/views/emails/html/negative_balance_reminder_degrade.blade.php +++ b/src/resources/views/emails/html/negative_balance_reminder_degrade.blade.php @@ -4,19 +4,19 @@ -

{{ __('mail.header', ['name' => $username]) }}

+

{{ __('mail.header', $vars) }}

-

{{ __('mail.negativebalancereminderdegrade-body', ['site' => $site]) }}

-

{{ __('mail.negativebalancereminderdegrade-body-ext', ['site' => $site]) }}

+

{{ __('mail.negativebalancereminderdegrade-body', $vars) }}

+

{{ __('mail.negativebalancereminderdegrade-body-ext', $vars) }}

{{ $walletUrl }}

-

{{ __('mail.negativebalancereminderdegrade-body-warning', ['site' => $site, 'date' => $date]) }}

+

{{ __('mail.negativebalancereminderdegrade-body-warning', $vars) }}

@if ($supportUrl) -

{{ __('mail.support', ['site' => $site]) }}

+

{{ __('mail.support', $vars) }}

{{ $supportUrl }}

@endif -

{{ __('mail.footer1') }}

-

{{ __('mail.footer2', ['site' => $site]) }}

+

{{ __('mail.footer1', $vars) }}

+

{{ __('mail.footer2', $vars) }}

diff --git a/src/resources/views/emails/html/password_expiration_reminder.blade.php b/src/resources/views/emails/html/password_expiration_reminder.blade.php --- a/src/resources/views/emails/html/password_expiration_reminder.blade.php +++ b/src/resources/views/emails/html/password_expiration_reminder.blade.php @@ -4,13 +4,13 @@ -

{{ __('mail.header', ['name' => $username]) }}

+

{{ __('mail.header', $vars) }}

-

{{ __('mail.passwordexpiration-body', ['site' => $site, 'date' => $date]) }} +

{{ __('mail.passwordexpiration-body', $vars) }}

{!! $link !!}

-

{{ __('mail.footer1') }}

-

{{ __('mail.footer2', ['site' => $site]) }}

+

{{ __('mail.footer1', $vars) }}

+

{{ __('mail.footer2', $vars) }}

diff --git a/src/resources/views/emails/html/password_reset.blade.php b/src/resources/views/emails/html/password_reset.blade.php --- a/src/resources/views/emails/html/password_reset.blade.php +++ b/src/resources/views/emails/html/password_reset.blade.php @@ -4,19 +4,19 @@ -

{{ __('mail.header', ['name' => $username]) }}

+

{{ __('mail.header', $vars) }}

-

{{ __('mail.passwordreset-body1', ['site' => $site]) }}
{{ __('mail.passwordreset-body2') }}

+

{{ __('mail.passwordreset-body1', $vars) }}
{{ __('mail.passwordreset-body2', $vars) }}

{!! $short_code !!}

-

{{ __('mail.passwordreset-body3') }}

+

{{ __('mail.passwordreset-body3', $vars) }}

{!! $link !!}

-

{{ __('mail.passwordreset-body4') }}

+

{{ __('mail.passwordreset-body4', $vars) }}

-

{{ __('mail.footer1') }}

-

{{ __('mail.footer2', ['site' => $site]) }}

+

{{ __('mail.footer1', $vars) }}

+

{{ __('mail.footer2', $vars) }}

diff --git a/src/resources/views/emails/html/payment_failure.blade.php b/src/resources/views/emails/html/payment_failure.blade.php --- a/src/resources/views/emails/html/payment_failure.blade.php +++ b/src/resources/views/emails/html/payment_failure.blade.php @@ -4,19 +4,19 @@ -

{{ __('mail.header', ['name' => $username]) }}

+

{{ __('mail.header', $vars) }}

-

{{ __('mail.paymentfailure-body', ['site' => $site]) }}

-

{{ __('mail.paymentfailure-body-ext', ['site' => $site]) }}

+

{{ __('mail.paymentfailure-body', $vars) }}

+

{{ __('mail.paymentfailure-body-ext', $vars) }}

{{ $walletUrl }}

-

{{ __('mail.paymentfailure-body-rest', ['site' => $site]) }}

+

{{ __('mail.paymentfailure-body-rest', $vars) }}

@if ($supportUrl) -

{{ __('mail.support', ['site' => $site]) }}

+

{{ __('mail.support', $vars) }}

{{ $supportUrl }}

@endif -

{{ __('mail.footer1') }}

-

{{ __('mail.footer2', ['site' => $site]) }}

+

{{ __('mail.footer1', $vars) }}

+

{{ __('mail.footer2', $vars) }}

diff --git a/src/resources/views/emails/html/payment_mandate_disabled.blade.php b/src/resources/views/emails/html/payment_mandate_disabled.blade.php --- a/src/resources/views/emails/html/payment_mandate_disabled.blade.php +++ b/src/resources/views/emails/html/payment_mandate_disabled.blade.php @@ -4,19 +4,19 @@ -

{{ __('mail.header', ['name' => $username]) }}

+

{{ __('mail.header', $vars) }}

-

{{ __('mail.paymentmandatedisabled-body', ['site' => $site]) }}

-

{{ __('mail.paymentmandatedisabled-body-ext', ['site' => $site]) }}

+

{{ __('mail.paymentmandatedisabled-body', $vars) }}

+

{{ __('mail.paymentmandatedisabled-body-ext', $vars) }}

{{ $walletUrl }}

-

{{ __('mail.paymentfailure-body-rest', ['site' => $site]) }}

+

{{ __('mail.paymentfailure-body-rest', $vars) }}

@if ($supportUrl) -

{{ __('mail.support', ['site' => $site]) }}

+

{{ __('mail.support', $vars) }}

{{ $supportUrl }}

@endif -

{{ __('mail.footer1') }}

-

{{ __('mail.footer2', ['site' => $site]) }}

+

{{ __('mail.footer1', $vars) }}

+

{{ __('mail.footer2', $vars) }}

diff --git a/src/resources/views/emails/html/payment_success.blade.php b/src/resources/views/emails/html/payment_success.blade.php --- a/src/resources/views/emails/html/payment_success.blade.php +++ b/src/resources/views/emails/html/payment_success.blade.php @@ -4,17 +4,17 @@ -

{{ __('mail.header', ['name' => $username]) }}

+

{{ __('mail.header', $vars) }}

-

{{ __('mail.paymentsuccess-body', ['site' => $site]) }}

+

{{ __('mail.paymentsuccess-body', $vars) }}

{{ $walletUrl }}

@if ($supportUrl) -

{{ __('mail.support', ['site' => $site]) }}

+

{{ __('mail.support', $vars) }}

{{ $supportUrl }}

@endif -

{{ __('mail.footer1') }}

-

{{ __('mail.footer2', ['site' => $site]) }}

+

{{ __('mail.footer1', $vars) }}

+

{{ __('mail.footer2', $vars) }}

diff --git a/src/resources/views/emails/html/signup_invitation.blade.php b/src/resources/views/emails/html/signup_invitation.blade.php --- a/src/resources/views/emails/html/signup_invitation.blade.php +++ b/src/resources/views/emails/html/signup_invitation.blade.php @@ -4,15 +4,15 @@ -

{{ __('mail.signupinvitation-header') }}

+

{{ __('mail.signupinvitation-header', $vars) }}

-

{{ __('mail.signupinvitation-body1', ['site' => $site]) }}

+

{{ __('mail.signupinvitation-body1', $vars) }}

{!! $href !!}

-

{{ __('mail.signupinvitation-body2') }}

+

{{ __('mail.signupinvitation-body2', $vars) }}

-

{{ __('mail.footer1') }}

-

{{ __('mail.footer2', ['site' => $site]) }}

+

{{ __('mail.footer1', $vars) }}

+

{{ __('mail.footer2', $vars) }}

diff --git a/src/resources/views/emails/html/signup_verification.blade.php b/src/resources/views/emails/html/signup_verification.blade.php --- a/src/resources/views/emails/html/signup_verification.blade.php +++ b/src/resources/views/emails/html/signup_verification.blade.php @@ -4,17 +4,17 @@ -

{{ __('mail.header', ['name' => $username]) }}

+

{{ __('mail.header', $vars) }}

-

{{ __('mail.signupverification-body1', ['site' => $site]) }}

+

{{ __('mail.signupverification-body1', $vars) }}

{!! $short_code !!}

-

{{ __('mail.signupverification-body2') }}

+

{{ __('mail.signupverification-body2', $vars) }}

{!! $href !!}

-

{{ __('mail.footer1') }}

-

{{ __('mail.footer2', ['site' => $site]) }}

+

{{ __('mail.footer1', $vars) }}

+

{{ __('mail.footer2', $vars) }}

diff --git a/src/resources/views/emails/html/trial_end.blade.php b/src/resources/views/emails/html/trial_end.blade.php --- a/src/resources/views/emails/html/trial_end.blade.php +++ b/src/resources/views/emails/html/trial_end.blade.php @@ -4,18 +4,18 @@ -

{{ __('mail.header', ['name' => $username]) }}

-

{{ __('mail.trialend-intro', ['site' => $site]) }}

+

{{ __('mail.header', $vars) }}

+

{{ __('mail.trialend-intro', $vars) }}

@if ($paymentUrl) -

{{ __('mail.trialend-kb', ['site' => $site]) }}

+

{{ __('mail.trialend-kb', $vars) }}

{{ $paymentUrl }}

@endif -

{{ __('mail.trialend-body1', ['site' => $site]) }}

-

{{ __('mail.trialend-body2', ['site' => $site]) }}

-

{{ __('mail.trialend-body3', ['site' => $site]) }}

+

{{ __('mail.trialend-body1', $vars) }}

+

{{ __('mail.trialend-body2', $vars) }}

+

{{ __('mail.trialend-body3', $vars) }}

{{ $supportUrl }}

-

{{ __('mail.footer1') }}

-

{{ __('mail.footer2', ['site' => $site]) }}

+

{{ __('mail.footer1', $vars) }}

+

{{ __('mail.footer2', $vars) }}

diff --git a/src/resources/views/emails/plain/degraded_account_reminder.blade.php b/src/resources/views/emails/plain/degraded_account_reminder.blade.php --- a/src/resources/views/emails/plain/degraded_account_reminder.blade.php +++ b/src/resources/views/emails/plain/degraded_account_reminder.blade.php @@ -1,17 +1,17 @@ -{!! __('mail.header', ['name' => $username]) !!} +{!! __('mail.header', $vars) !!} -{!! __('mail.degradedaccountreminder-body1', ['site' => $site]) !!} +{!! __('mail.degradedaccountreminder-body1', $vars) !!} -{!! __('mail.degradedaccountreminder-body2', ['site' => $site]) !!} +{!! __('mail.degradedaccountreminder-body2', $vars) !!} -{!! __('mail.degradedaccountreminder-body3', ['site' => $site]) !!} +{!! __('mail.degradedaccountreminder-body3', $vars) !!} {!! $dashboardUrl !!} -{!! __('mail.degradedaccountreminder-body4', ['site' => $site]) !!} +{!! __('mail.degradedaccountreminder-body4', $vars) !!} -{!! __('mail.degradedaccountreminder-body5', ['site' => $site]) !!} +{!! __('mail.degradedaccountreminder-body5', $vars) !!} -- -{!! __('mail.footer1') !!} -{!! __('mail.footer2', ['site' => $site]) !!} +{!! __('mail.footer1', $vars) !!} +{!! __('mail.footer2', $vars) !!} diff --git a/src/resources/views/emails/plain/negative_balance.blade.php b/src/resources/views/emails/plain/negative_balance.blade.php --- a/src/resources/views/emails/plain/negative_balance.blade.php +++ b/src/resources/views/emails/plain/negative_balance.blade.php @@ -1,17 +1,17 @@ -{!! __('mail.header', ['name' => $username]) !!} +{!! __('mail.header', $vars) !!} -{!! __('mail.negativebalance-body', ['site' => $site]) !!} +{!! __('mail.negativebalance-body', $vars) !!} -{!! __('mail.negativebalance-body-ext', ['site' => $site]) !!} +{!! __('mail.negativebalance-body-ext', $vars) !!} {!! $walletUrl !!} @if ($supportUrl) -{!! __('mail.support', ['site' => $site]) !!} +{!! __('mail.support', $vars) !!} {!! $supportUrl !!} @endif -- -{!! __('mail.footer1') !!} -{!! __('mail.footer2', ['site' => $site]) !!} +{!! __('mail.footer1', $vars) !!} +{!! __('mail.footer2', $vars) !!} diff --git a/src/resources/views/emails/plain/negative_balance_degraded.blade.php b/src/resources/views/emails/plain/negative_balance_degraded.blade.php --- a/src/resources/views/emails/plain/negative_balance_degraded.blade.php +++ b/src/resources/views/emails/plain/negative_balance_degraded.blade.php @@ -1,17 +1,17 @@ -{!! __('mail.header', ['name' => $username]) !!} +{!! __('mail.header', $vars) !!} -{!! __('mail.negativebalancedegraded-body', ['site' => $site]) !!} +{!! __('mail.negativebalancedegraded-body', $vars) !!} -{!! __('mail.negativebalancedegraded-body-ext', ['site' => $site]) !!} +{!! __('mail.negativebalancedegraded-body-ext', $vars) !!} {!! $walletUrl !!} @if ($supportUrl) -{!! __('mail.support', ['site' => $site]) !!} +{!! __('mail.support', $vars) !!} {!! $supportUrl !!} @endif -- -{!! __('mail.footer1') !!} -{!! __('mail.footer2', ['site' => $site]) !!} +{!! __('mail.footer1', $vars) !!} +{!! __('mail.footer2', $vars) !!} diff --git a/src/resources/views/emails/plain/negative_balance_reminder_degrade.blade.php b/src/resources/views/emails/plain/negative_balance_reminder_degrade.blade.php --- a/src/resources/views/emails/plain/negative_balance_reminder_degrade.blade.php +++ b/src/resources/views/emails/plain/negative_balance_reminder_degrade.blade.php @@ -1,19 +1,19 @@ -{!! __('mail.header', ['name' => $username]) !!} +{!! __('mail.header', $vars) !!} -{!! __('mail.negativebalancereminderdegrade-body', ['site' => $site]) !!} +{!! __('mail.negativebalancereminderdegrade-body', $vars) !!} -{!! __('mail.negativebalancereminderdegrade-body-ext', ['site' => $site]) !!} +{!! __('mail.negativebalancereminderdegrade-body-ext', $vars) !!} {!! $walletUrl !!} -{!! __('mail.negativebalancereminderdegrade-body-warning', ['site' => $site, 'date' => $date]) !!} +{!! __('mail.negativebalancereminderdegrade-body-warning', $vars) !!} @if ($supportUrl) -{!! __('mail.support', ['site' => $site]) !!} +{!! __('mail.support', $vars) !!} {!! $supportUrl !!} @endif -- -{!! __('mail.footer1') !!} -{!! __('mail.footer2', ['site' => $site]) !!} +{!! __('mail.footer1', $vars) !!} +{!! __('mail.footer2', $vars) !!} diff --git a/src/resources/views/emails/plain/password_expiration_reminder.blade.php b/src/resources/views/emails/plain/password_expiration_reminder.blade.php --- a/src/resources/views/emails/plain/password_expiration_reminder.blade.php +++ b/src/resources/views/emails/plain/password_expiration_reminder.blade.php @@ -1,9 +1,9 @@ -{!! __('mail.header', ['name' => $username]) !!} +{!! __('mail.header', $vars) !!} -{!! __('mail.passwordexpiration-body', ['site' => $site, 'date' => $date]) !!} +{!! __('mail.passwordexpiration-body', $vars) !!} {!! $link !!} -- -{!! __('mail.footer1') !!} -{!! __('mail.footer2', ['site' => $site]) !!} +{!! __('mail.footer1', $vars) !!} +{!! __('mail.footer2', $vars) !!} diff --git a/src/resources/views/emails/plain/password_reset.blade.php b/src/resources/views/emails/plain/password_reset.blade.php --- a/src/resources/views/emails/plain/password_reset.blade.php +++ b/src/resources/views/emails/plain/password_reset.blade.php @@ -1,16 +1,16 @@ -{!! __('mail.header', ['name' => $username]) !!} +{!! __('mail.header', $vars) !!} -{!! __('mail.passwordreset-body1', ['site' => $site]) !!} -{!! __('mail.passwordreset-body2') !!} +{!! __('mail.passwordreset-body1', $vars) !!} +{!! __('mail.passwordreset-body2', $vars) !!} {!! $short_code !!} -{!! __('mail.passwordreset-body3') !!} +{!! __('mail.passwordreset-body3', $vars) !!} {!! $link !!} -{!! __('mail.passwordreset-body4') !!} +{!! __('mail.passwordreset-body4', $vars) !!} -- -{!! __('mail.footer1') !!} -{!! __('mail.footer2', ['site' => $site]) !!} +{!! __('mail.footer1', $vars) !!} +{!! __('mail.footer2', $vars) !!} diff --git a/src/resources/views/emails/plain/payment_failure.blade.php b/src/resources/views/emails/plain/payment_failure.blade.php --- a/src/resources/views/emails/plain/payment_failure.blade.php +++ b/src/resources/views/emails/plain/payment_failure.blade.php @@ -1,19 +1,19 @@ -{!! __('mail.header', ['name' => $username]) !!} +{!! __('mail.header', $vars) !!} -{!! __('mail.paymentfailure-body', ['site' => $site]) !!} +{!! __('mail.paymentfailure-body', $vars) !!} -{!! __('mail.paymentfailure-body-ext', ['site' => $site]) !!} +{!! __('mail.paymentfailure-body-ext', $vars) !!} {!! $walletUrl !!} -{!! __('mail.paymentfailure-body-rest', ['site' => $site]) !!} +{!! __('mail.paymentfailure-body-rest', $vars) !!} @if ($supportUrl) -{!! __('mail.support', ['site' => $site]) !!} +{!! __('mail.support', $vars) !!} {!! $supportUrl !!} @endif -- -{!! __('mail.footer1') !!} -{!! __('mail.footer2', ['site' => $site]) !!} \ No newline at end of file +{!! __('mail.footer1', $vars) !!} +{!! __('mail.footer2', $vars) !!} \ No newline at end of file diff --git a/src/resources/views/emails/plain/payment_mandate_disabled.blade.php b/src/resources/views/emails/plain/payment_mandate_disabled.blade.php --- a/src/resources/views/emails/plain/payment_mandate_disabled.blade.php +++ b/src/resources/views/emails/plain/payment_mandate_disabled.blade.php @@ -1,19 +1,19 @@ -{!! __('mail.header', ['name' => $username]) !!} +{!! __('mail.header', $vars) !!} -{!! __('mail.paymentmandatedisabled-body', ['site' => $site]) !!} +{!! __('mail.paymentmandatedisabled-body', $vars) !!} -{!! __('mail.paymentmandatedisabled-body-ext', ['site' => $site]) !!} +{!! __('mail.paymentmandatedisabled-body-ext', $vars) !!} {!! $walletUrl !!} -{!! __('mail.paymentfailure-body-rest', ['site' => $site]) !!} +{!! __('mail.paymentfailure-body-rest', $vars) !!} @if ($supportUrl) -{!! __('mail.support', ['site' => $site]) !!} +{!! __('mail.support', $vars) !!} {!! $supportUrl !!} @endif -- -{!! __('mail.footer1') !!} -{!! __('mail.footer2', ['site' => $site]) !!} +{!! __('mail.footer1', $vars) !!} +{!! __('mail.footer2', $vars) !!} diff --git a/src/resources/views/emails/plain/payment_success.blade.php b/src/resources/views/emails/plain/payment_success.blade.php --- a/src/resources/views/emails/plain/payment_success.blade.php +++ b/src/resources/views/emails/plain/payment_success.blade.php @@ -1,15 +1,15 @@ -{!! __('mail.header', ['name' => $username]) !!} +{!! __('mail.header', $vars) !!} -{!! __('mail.paymentsuccess-body', ['site' => $site]) !!} +{!! __('mail.paymentsuccess-body', $vars) !!} {!! $walletUrl !!} @if ($supportUrl) -{!! __('mail.support', ['site' => $site]) !!} +{!! __('mail.support', $vars) !!} {!! $supportUrl !!} @endif -- -{!! __('mail.footer1') !!} -{!! __('mail.footer2', ['site' => $site]) !!} \ No newline at end of file +{!! __('mail.footer1', $vars) !!} +{!! __('mail.footer2', $vars) !!} \ No newline at end of file diff --git a/src/resources/views/emails/plain/signup_invitation.blade.php b/src/resources/views/emails/plain/signup_invitation.blade.php --- a/src/resources/views/emails/plain/signup_invitation.blade.php +++ b/src/resources/views/emails/plain/signup_invitation.blade.php @@ -1,11 +1,11 @@ -{!! __('mail.signupinvitation-header') !!} +{!! __('mail.signupinvitation-header', $vars) !!} -{!! __('mail.signupinvitation-body1', ['site' => $site]) !!} +{!! __('mail.signupinvitation-body1', $vars) !!} {!! $href !!} -{!! __('mail.signupinvitation-body2') !!} +{!! __('mail.signupinvitation-body2', $vars) !!} -- -{!! __('mail.footer1') !!} -{!! __('mail.footer2', ['site' => $site]) !!} +{!! __('mail.footer1', $vars) !!} +{!! __('mail.footer2', $vars) !!} diff --git a/src/resources/views/emails/plain/signup_verification.blade.php b/src/resources/views/emails/plain/signup_verification.blade.php --- a/src/resources/views/emails/plain/signup_verification.blade.php +++ b/src/resources/views/emails/plain/signup_verification.blade.php @@ -1,13 +1,13 @@ -{!! __('mail.header', ['name' => $username]) !!} +{!! __('mail.header', $vars) !!} -{!! __('mail.signupverification-body1', ['site' => $site]) !!} +{!! __('mail.signupverification-body1', $vars) !!} {!! $short_code !!} -{!! __('mail.signupverification-body2') !!} +{!! __('mail.signupverification-body2', $vars) !!} {!! $href !!} -- -{!! __('mail.footer1') !!} -{!! __('mail.footer2', ['site' => $site]) !!} +{!! __('mail.footer1', $vars) !!} +{!! __('mail.footer2', $vars) !!} diff --git a/src/resources/views/emails/plain/trial_end.blade.php b/src/resources/views/emails/plain/trial_end.blade.php --- a/src/resources/views/emails/plain/trial_end.blade.php +++ b/src/resources/views/emails/plain/trial_end.blade.php @@ -1,19 +1,19 @@ -{!! __('mail.header', ['name' => $username]) !!} +{!! __('mail.header', $vars) !!} -{!! __('mail.trialend-intro', ['site' => $site]) !!} +{!! __('mail.trialend-intro', $vars) !!} @if ($paymentUrl) -{!! __('mail.trialend-kb', ['site' => $site]) !!} {!! $paymentUrl !!} +{!! __('mail.trialend-kb', $vars) !!} {!! $paymentUrl !!} @endif -{!! __('mail.trialend-body1', ['site' => $site]) !!} +{!! __('mail.trialend-body1', $vars) !!} -{!! __('mail.trialend-body2', ['site' => $site]) !!} +{!! __('mail.trialend-body2', $vars) !!} -{!! __('mail.trialend-body3', ['site' => $site]) !!} +{!! __('mail.trialend-body3', $vars) !!} {!! $supportUrl !!} -- -{!! __('mail.footer1') !!} -{!! __('mail.footer2', ['site' => $site]) !!} +{!! __('mail.footer1', $vars) !!} +{!! __('mail.footer2', $vars) !!} diff --git a/src/tests/Unit/Mail/DegradedAccountReminderTest.php b/src/tests/Unit/Mail/DegradedAccountReminderTest.php --- a/src/tests/Unit/Mail/DegradedAccountReminderTest.php +++ b/src/tests/Unit/Mail/DegradedAccountReminderTest.php @@ -15,7 +15,8 @@ public function testBuild(): void { $user = $this->getTestUser('ned@kolab.org'); - $wallet = $user->wallets->first(); + $john = $this->getTestUser('john@kolab.org'); + $wallet = $john->wallets->first(); $mail = $this->renderMail(new DegradedAccountReminder($wallet, $user)); @@ -31,12 +32,12 @@ $this->assertStringStartsWith('', $html); $this->assertTrue(strpos($html, $user->name(true)) > 0); $this->assertTrue(strpos($html, $dashboardLink) > 0); - $this->assertTrue(strpos($html, "your account is a free account") > 0); + $this->assertTrue(strpos($html, "your {$john->email} account is a free account") > 0); $this->assertTrue(strpos($html, "$appName Team") > 0); $this->assertStringStartsWith('Dear ' . $user->name(true), $plain); $this->assertTrue(strpos($plain, $dashboardUrl) > 0); - $this->assertTrue(strpos($plain, "your account is a free account") > 0); + $this->assertTrue(strpos($plain, "your {$john->email} account is a free account") > 0); $this->assertTrue(strpos($plain, "$appName Team") > 0); } diff --git a/src/tests/Unit/Mail/NegativeBalanceDegradedTest.php b/src/tests/Unit/Mail/NegativeBalanceDegradedTest.php --- a/src/tests/Unit/Mail/NegativeBalanceDegradedTest.php +++ b/src/tests/Unit/Mail/NegativeBalanceDegradedTest.php @@ -16,7 +16,8 @@ public function testBuild(): void { $user = $this->getTestUser('ned@kolab.org'); - $wallet = $user->wallets->first(); + $john = $this->getTestUser('john@kolab.org'); + $wallet = $john->wallets->first(); $wallet->balance = -100; $wallet->save(); @@ -41,14 +42,14 @@ $this->assertTrue(strpos($html, $user->name(true)) > 0); $this->assertTrue(strpos($html, $walletLink) > 0); $this->assertTrue(strpos($html, $supportLink) > 0); - $this->assertTrue(strpos($html, "Your $appName account has been degraded") > 0); + $this->assertTrue(strpos($html, "Your {$john->email} account has been degraded") > 0); $this->assertTrue(strpos($html, "$appName Support") > 0); $this->assertTrue(strpos($html, "$appName Team") > 0); $this->assertStringStartsWith('Dear ' . $user->name(true), $plain); $this->assertTrue(strpos($plain, $walletUrl) > 0); $this->assertTrue(strpos($plain, $supportUrl) > 0); - $this->assertTrue(strpos($plain, "Your $appName account has been degraded") > 0); + $this->assertTrue(strpos($plain, "Your {$john->email} account has been degraded") > 0); $this->assertTrue(strpos($plain, "$appName Support") > 0); $this->assertTrue(strpos($plain, "$appName Team") > 0); } diff --git a/src/tests/Unit/Mail/NegativeBalanceReminderDegradeTest.php b/src/tests/Unit/Mail/NegativeBalanceReminderDegradeTest.php --- a/src/tests/Unit/Mail/NegativeBalanceReminderDegradeTest.php +++ b/src/tests/Unit/Mail/NegativeBalanceReminderDegradeTest.php @@ -16,7 +16,8 @@ public function testBuild(): void { $user = $this->getTestUser('ned@kolab.org'); - $wallet = $user->wallets->first(); + $john = $this->getTestUser('john@kolab.org'); + $wallet = $john->wallets->first(); $wallet->balance = -100; $wallet->save(); @@ -43,7 +44,7 @@ $this->assertTrue(strpos($html, $user->name(true)) > 0); $this->assertTrue(strpos($html, $walletLink) > 0); $this->assertTrue(strpos($html, $supportLink) > 0); - $this->assertTrue(strpos($html, "you are behind on paying for your $appName account") > 0); + $this->assertTrue(strpos($html, "you are behind on paying for your {$john->email} account") > 0); $this->assertTrue(strpos($html, "your account will be degraded") > 0); $this->assertTrue(strpos($html, $threshold->toDateString()) > 0); $this->assertTrue(strpos($html, "$appName Support") > 0); @@ -52,7 +53,7 @@ $this->assertStringStartsWith('Dear ' . $user->name(true), $plain); $this->assertTrue(strpos($plain, $walletUrl) > 0); $this->assertTrue(strpos($plain, $supportUrl) > 0); - $this->assertTrue(strpos($plain, "you are behind on paying for your $appName account") > 0); + $this->assertTrue(strpos($plain, "you are behind on paying for your {$john->email} account") > 0); $this->assertTrue(strpos($plain, "your account will be degraded") > 0); $this->assertTrue(strpos($plain, $threshold->toDateString()) > 0); $this->assertTrue(strpos($plain, "$appName Support") > 0); diff --git a/src/tests/Unit/Mail/NegativeBalanceTest.php b/src/tests/Unit/Mail/NegativeBalanceTest.php --- a/src/tests/Unit/Mail/NegativeBalanceTest.php +++ b/src/tests/Unit/Mail/NegativeBalanceTest.php @@ -4,6 +4,7 @@ use App\Mail\NegativeBalance; use App\User; +use App\Tenant; use App\Wallet; use Tests\TestCase; @@ -14,8 +15,8 @@ */ public function testBuild(): void { - $user = new User(); - $wallet = new Wallet(); + $user = $this->getTestUser('john@kolab.org'); + $wallet = $user->wallets->first(); \config([ 'app.support_url' => 'https://kolab.org/support', @@ -30,7 +31,7 @@ $walletLink = sprintf('%s', $walletUrl, $walletUrl); $supportUrl = \config('app.support_url'); $supportLink = sprintf('%s', $supportUrl, $supportUrl); - $appName = \config('app.name'); + $appName = Tenant::getConfig($user->tenant_id, 'app.name'); $this->assertSame("$appName Payment Required", $mail['subject']); @@ -38,14 +39,14 @@ $this->assertTrue(strpos($html, $user->name(true)) > 0); $this->assertTrue(strpos($html, $walletLink) > 0); $this->assertTrue(strpos($html, $supportLink) > 0); - $this->assertTrue(strpos($html, "your $appName account balance has run into the nega") > 0); + $this->assertTrue(strpos($html, "your {$user->email} account balance has run into the nega") > 0); $this->assertTrue(strpos($html, "$appName Support") > 0); $this->assertTrue(strpos($html, "$appName Team") > 0); $this->assertStringStartsWith('Dear ' . $user->name(true), $plain); $this->assertTrue(strpos($plain, $walletUrl) > 0); $this->assertTrue(strpos($plain, $supportUrl) > 0); - $this->assertTrue(strpos($plain, "your $appName account balance has run into the nega") > 0); + $this->assertTrue(strpos($plain, "your {$user->email} account balance has run into the nega") > 0); $this->assertTrue(strpos($plain, "$appName Support") > 0); $this->assertTrue(strpos($plain, "$appName Team") > 0); } diff --git a/src/tests/Unit/Mail/PasswordExpirationReminderTest.php b/src/tests/Unit/Mail/PasswordExpirationReminderTest.php --- a/src/tests/Unit/Mail/PasswordExpirationReminderTest.php +++ b/src/tests/Unit/Mail/PasswordExpirationReminderTest.php @@ -14,9 +14,7 @@ */ public function testBuild(): void { - $user = new User([ - 'name' => 'User Name', - ]); + $user = new User(['email' => 'test@user']); $expiresOn = now()->copy()->addDays(7)->toDateString(); @@ -35,10 +33,12 @@ $this->assertTrue(strpos($html, $link) > 0); $this->assertTrue(strpos($html, $user->name(true)) > 0); $this->assertTrue(strpos($html, $expiresOn) > 0); + $this->assertTrue(strpos($html, $user->email) > 0); $this->assertStringStartsWith("Dear " . $user->name(true), $plain); $this->assertTrue(strpos($plain, $link) > 0); $this->assertTrue(strpos($plain, $expiresOn) > 0); + $this->assertTrue(strpos($plain, $user->email) > 0); } /** @@ -46,7 +46,7 @@ */ public function testGetSubjectAndUser(): void { - $user = new User(['name' => 'User Name']); + $user = new User(); $appName = \config('app.name'); $expiresOn = now()->copy()->addDays(7)->toDateString(); diff --git a/src/tests/Unit/Mail/PasswordResetTest.php b/src/tests/Unit/Mail/PasswordResetTest.php --- a/src/tests/Unit/Mail/PasswordResetTest.php +++ b/src/tests/Unit/Mail/PasswordResetTest.php @@ -23,9 +23,7 @@ ]); // @phpstan-ignore-next-line - $code->user = new User([ - 'name' => 'User Name', - ]); + $code->user = new User(['email' => 'test@user']); $mail = $this->renderMail(new PasswordReset($code)); @@ -41,9 +39,11 @@ $this->assertStringStartsWith('', $html); $this->assertTrue(strpos($html, $link) > 0); $this->assertTrue(strpos($html, $code->user->name(true)) > 0); + $this->assertTrue(strpos($html, $code->user->email) > 0); $this->assertStringStartsWith("Dear " . $code->user->name(true), $plain); $this->assertTrue(strpos($plain, $link) > 0); + $this->assertTrue(strpos($plain, $code->user->email) > 0); } /** @@ -60,7 +60,7 @@ ]); // @phpstan-ignore-next-line - $code->user = new User(['name' => 'User Name']); + $code->user = new User(); $mail = new PasswordReset($code); diff --git a/src/tests/Unit/Mail/PaymentFailureTest.php b/src/tests/Unit/Mail/PaymentFailureTest.php --- a/src/tests/Unit/Mail/PaymentFailureTest.php +++ b/src/tests/Unit/Mail/PaymentFailureTest.php @@ -5,6 +5,7 @@ use App\Mail\PaymentFailure; use App\Payment; use App\User; +use App\Wallet; use Tests\TestCase; class PaymentFailureTest extends TestCase @@ -14,9 +15,11 @@ */ public function testBuild(): void { - $user = new User(); + $user = new User(['email' => 'test@user']); $payment = new Payment(); $payment->amount = 123; + $payment->wallet = new Wallet(); + $payment->wallet->owner = $user; \config(['app.support_url' => 'https://kolab.org/support']); @@ -38,14 +41,14 @@ $this->assertTrue(strpos($html, $walletLink) > 0); $this->assertTrue(strpos($html, $supportLink) > 0); $this->assertTrue(strpos($html, "$appName Support") > 0); - $this->assertTrue(strpos($html, "Something went wrong with auto-payment for your $appName account") > 0); + $this->assertTrue(strpos($html, "Something went wrong with auto-payment for your {$user->email} account") > 0); $this->assertTrue(strpos($html, "$appName Team") > 0); $this->assertStringStartsWith('Dear ' . $user->name(true), $plain); $this->assertTrue(strpos($plain, $walletUrl) > 0); $this->assertTrue(strpos($plain, $supportUrl) > 0); $this->assertTrue(strpos($plain, "$appName Support") > 0); - $this->assertTrue(strpos($plain, "Something went wrong with auto-payment for your $appName account") > 0); + $this->assertTrue(strpos($plain, "Something went wrong with auto-payment for your {$user->email} account") > 0); $this->assertTrue(strpos($plain, "$appName Team") > 0); } @@ -56,6 +59,7 @@ { $user = new User(); $user->id = 1234; + $user->email = 'test@user'; $payment = new Payment(); $payment->amount = 123; $appName = \config('app.name'); diff --git a/src/tests/Unit/Mail/PaymentMandateDisabledTest.php b/src/tests/Unit/Mail/PaymentMandateDisabledTest.php --- a/src/tests/Unit/Mail/PaymentMandateDisabledTest.php +++ b/src/tests/Unit/Mail/PaymentMandateDisabledTest.php @@ -3,8 +3,9 @@ namespace Tests\Unit\Mail; use App\Mail\PaymentMandateDisabled; -use App\Wallet; +use App\Tenant; use App\User; +use App\Wallet; use Tests\TestCase; class PaymentMandateDisabledTest extends TestCase @@ -14,8 +15,8 @@ */ public function testBuild(): void { - $user = new User(); - $wallet = new Wallet(); + $user = $this->getTestUser('john@kolab.org'); + $wallet = $user->wallets->first(); \config(['app.support_url' => 'https://kolab.org/support']); @@ -28,7 +29,7 @@ $walletLink = sprintf('%s', $walletUrl, $walletUrl); $supportUrl = \config('app.support_url'); $supportLink = sprintf('%s', $supportUrl, $supportUrl); - $appName = \config('app.name'); + $appName = Tenant::getConfig($user->tenant_id, 'app.name'); $this->assertSame("$appName Auto-payment Problem", $mail['subject']); @@ -37,14 +38,14 @@ $this->assertTrue(strpos($html, $walletLink) > 0); $this->assertTrue(strpos($html, $supportLink) > 0); $this->assertTrue(strpos($html, "$appName Support") > 0); - $this->assertTrue(strpos($html, "Your $appName account balance") > 0); + $this->assertTrue(strpos($html, "Your {$user->email} account balance") > 0); $this->assertTrue(strpos($html, "$appName Team") > 0); $this->assertStringStartsWith('Dear ' . $user->name(true), $plain); $this->assertTrue(strpos($plain, $walletUrl) > 0); $this->assertTrue(strpos($plain, $supportUrl) > 0); $this->assertTrue(strpos($plain, "$appName Support") > 0); - $this->assertTrue(strpos($plain, "Your $appName account balance") > 0); + $this->assertTrue(strpos($plain, "Your {$user->email} account balance") > 0); $this->assertTrue(strpos($plain, "$appName Team") > 0); } diff --git a/src/tests/Unit/Mail/PaymentSuccessTest.php b/src/tests/Unit/Mail/PaymentSuccessTest.php --- a/src/tests/Unit/Mail/PaymentSuccessTest.php +++ b/src/tests/Unit/Mail/PaymentSuccessTest.php @@ -4,6 +4,7 @@ use App\Mail\PaymentSuccess; use App\Payment; +use App\Tenant; use App\User; use Tests\TestCase; @@ -14,9 +15,10 @@ */ public function testBuild(): void { - $user = new User(); + $user = $this->getTestUser('john@kolab.org'); $payment = new Payment(); $payment->amount = 123; + $payment->wallet = $user->wallets->first(); \config(['app.support_url' => 'https://kolab.org/support']); @@ -29,7 +31,7 @@ $walletLink = sprintf('%s', $walletUrl, $walletUrl); $supportUrl = \config('app.support_url'); $supportLink = sprintf('%s', $supportUrl, $supportUrl); - $appName = \config('app.name'); + $appName = Tenant::getConfig($user->tenant_id, 'app.name'); $this->assertSame("$appName Payment Succeeded", $mail['subject']); @@ -38,14 +40,14 @@ $this->assertTrue(strpos($html, $walletLink) > 0); $this->assertTrue(strpos($html, $supportLink) > 0); $this->assertTrue(strpos($html, "$appName Support") > 0); - $this->assertTrue(strpos($html, "The auto-payment for your $appName account") > 0); + $this->assertTrue(strpos($html, "The auto-payment for your {$user->email} account") > 0); $this->assertTrue(strpos($html, "$appName Team") > 0); $this->assertStringStartsWith('Dear ' . $user->name(true), $plain); $this->assertTrue(strpos($plain, $walletUrl) > 0); $this->assertTrue(strpos($plain, $supportUrl) > 0); $this->assertTrue(strpos($plain, "$appName Support") > 0); - $this->assertTrue(strpos($plain, "The auto-payment for your $appName account") > 0); + $this->assertTrue(strpos($plain, "The auto-payment for your {$user->email} account") > 0); $this->assertTrue(strpos($plain, "$appName Team") > 0); } @@ -54,11 +56,12 @@ */ public function testGetSubjectAndUser(): void { - $user = new User(); - $user->id = 1234; + $user = $this->getTestUser('john@kolab.org'); $payment = new Payment(); $payment->amount = 123; - $appName = \config('app.name'); + $payment->wallet = $user->wallets->first(); + + $appName = Tenant::getConfig($user->tenant_id, 'app.name'); $mail = new PaymentSuccess($payment, $user);